<template>
  <a-modal :open="open" width="640px" :title="rowData?.id ? '修改血液申请' : '新增血液申请'" centered :keyboard="false" @ok="onOk" @cancel="onCancel">
    <a-form :model="formState" :colon="false">
      <a-form-item label="情况描述" class="w-full">
        <a-textarea v-model:value="formState.appDesc" :rows="6" placeholder="请输入" />
      </a-form-item>
    </a-form>
  </a-modal>
</template>

<script setup>
import { ref, watch } from 'vue'
import { message } from 'ant-design-vue'
import { post } from '@/utils/request'

const props = defineProps({
  open: Boolean,
  rowData: {
    type: Object,
    default: () => ({})
  }
})

const emit = defineEmits(['update:open', 'success'])
const formState = ref({
  nurseLevelName: '',
  zjm: ''
})

const onOk = async () => {
  const res = await post('/bloodm/bldApplicationRecord/doSaveBldApplicationRecord', formState.value)
  res.code !== 0 ? message.error(res.msg || '操作失败') : message.success('保存成功')
  onCancel()
  emit('success')
}
const onCancel = () => {
  emit('update:open', false)
}
watch(
  () => props.open,
  () => {
    formState.value = { ...props.rowData }
  }
)
</script>
<style lang="less" scoped>
.ant-form {
  display: flex;
  flex-flow: row wrap;
  min-width: 0;
  :deep(.ant-form-item) {
    .ant-form-item-label {
      width: 100px;
    }
  }
  .ant-picker {
    width: 100%;
  }
}
</style>
